﻿@inherits System.Web.Mvc.WebViewPage<Pikapika.Models.ViewModels.Novel.NovelDisplayModel>

@{
	ViewBag.Title = Model.Novel.Name;
    ViewBag.BodyClassName = "hide-sidebar";
	int novelImageThumbnailWidth = 200, novelImageThumbnailHeight = 10000;
	int novelVolumeImageThumbnailWidth = 150, novelVolumeImageThumbnailHeight = 10000;
    int chaptersPerRow = 4;
}

<div class="novel-info">
	<h2 class="novel-name">@Model.Novel.Name</h2>
	<div class="novel-image">
		@if (String.IsNullOrWhiteSpace(Model.Novel.ImageUrl)) {
			<span class="novel-image-placeholder-big"></span>
		} else {
            @Html.ThumbnailImage(Model.Novel.ImageUrl, novelImageThumbnailWidth, novelImageThumbnailHeight, true)
		}
	</div>
	<div class="novel-info-fields">
		更新
		@Model.TimeZoneCorrectedUpdatedDate.ToString("yyyy-MM-dd HH:mm")
	</div>
	<div class="novel-info-fields">
		作者
		@Model.Novel.Author
	</div>
	<div class="novel-info-fields novel-publisher">
		出版
		@Html.ActionLink(Model.Novel.Publisher.Name,
						"List",
						new { id = Model.Novel.Publisher.Id, publisher = Model.Novel.Publisher.Name })
	</div>
	<div class="novel-info-fields">
		点击
		@Model.HitCount
	</div>
	<div class="novel-info-fields">
		吐槽
		@Model.AnnotationCount
	</div>
	@if (Model.LatestChapter != null) {
		<div class="novel-latest-chapter novel-info-fields">
			最新章节：
			@Html.ActionLinkForModel(Model.LatestChapter,
                            String.Format("{0} - {1}", Model.LatestVolume.Name, Model.LatestChapter.Name),
							new RouteValueDictionary { {"class", "novel-latest-chapter-link"} }, 
                            Model.Novel,
                            Model.LatestVolume)
		</div>
	}
	<div class="novel-description">
		@{WriteLiteral(Html.Encode(Model.Novel.Description.Trim()).Replace("\n", "<br/>"));}
	</div>
	<div class="novel-info-fields novel-tags">
	    <span class="tag-title">标签</span>
		@foreach (var tag in Model.Novel.NovelTags) {
            <span class="novel-tag">@tag.Tag</span>
        }
        <a href="#" id="add-tag-link"> [新增] </a>
        <span id="add-tag" style="display: none;">
            <input type="text" maxlength="50" id="add-tag-content" />
            <a id="add-tag-submit" href="#"> [提交] </a>
            <span class="error-message"></span>
        </span>
	</div>
</div>
	
<div class="clear"></div>

<div class="novel-volume-list">
	@foreach (var volume in Model.Novel.GetSortedVolumes()) {
		<div class="novel-volume">
			<h3 class="novel-volume-name">
				@volume.Name
			</h3>
			@if (!String.IsNullOrWhiteSpace(volume.ImageUrl)) {
				<div class="novel-volume-image">
                    @Html.ThumbnailImage(volume.ImageUrl, novelVolumeImageThumbnailWidth, novelVolumeImageThumbnailHeight, true)
				</div>
			}
			@if (!String.IsNullOrWhiteSpace(volume.Description)) {
				<div class="novel-volume-description">
					@{WriteLiteral(Html.Encode(volume.Description).Replace("\n", "<br/>"));}
				</div>
			}
			<div class="clear"></div>
			<ul class="novel-volume-chapter-list">
                @{ var chapterIndex = 0; }
				@foreach (var chapter in volume.GetSortedChapters()) {
                    <text>
                        <li
                        @if (chapterIndex > 0 && chapterIndex % chaptersPerRow == 0) {
					        <text> class="clear"</text>
                        }
                        >
                            @Html.ActionLinkForModel(chapter, Model.Novel, volume)
                        </li>
                        @{ chapterIndex++; }
                    </text>
				}
			</ul>
			<div class="novel-volume-chapter-list-end"></div>
		</div>
	}
</div>
	

@section Head {
    <meta name="description" content="@Model.Novel.Description.Trim().Replace("\n", "")" />
	@Html.Css("Novel/Details.css?20101128")
    @Html.Css("Novel/DetailsMobile.css", (string)ViewBag.MobileMediaSelector)
    @Html.Script(StandardLibraries.Jquery)
    <script type="text/javascript">
        //<![CDATA[
        var novelId = @Model.Novel.Id;
        var addTagUrl = '@Url.Action("Add", "Tag")';
        //]]>
    </script>
    @Html.Script("Novel/Details.js")
    <link href="@Url.Action("LatestChapterSummary", "Feed", new { id = Model.Novel.Id })" type="application/atom+xml" rel="alternate" title="最近更新摘要" />
    <link href="@Url.Action("LatestChapters", "Feed", new { id = Model.Novel.Id })" type="application/atom+xml" rel="alternate" title="最近更新" />
}